﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

/// <summary>
/// 字符串扩展类
/// </summary>
public static class YJUtilityStringExtensions
{
    public static bool IsNullOrWhiteSpace(this string str)
    {
        return string.IsNullOrWhiteSpace(str);
    }

    public static List<T> Split<T>(this string str, params string[] separators)
    {
        if (string.IsNullOrWhiteSpace(str))
            return new List<T>();
        return str.Split(separators, StringSplitOptions.RemoveEmptyEntries).Select(YJUtilityConvertor.ConvertTo<T>).ToList();
    }

    public static bool Contains(this string source, string value, StringComparison stringComparison)
    {
        if (source == null || value == null) { return false; }
        if (value == "") { return true; }
        return (source.IndexOf(value, stringComparison) >= 0);
    }
}

